package com.cn.yang.servlet;

import com.alibaba.fastjson.JSONObject;
import com.cn.yang.model.mainPage.HeadAndFootModel;
import com.cn.yang.model.mainPage.HeadLinkModel;
import com.cn.yang.service.MainPageService;
import com.cn.yang.service.impl.MainPageServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/headandfoot")
public class HeadAndFootServlet extends HttpServlet {
    
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
    
        MainPageService headFootService = new MainPageServiceImpl();
        HeadAndFootModel model = headFootService.selectHeadFoot();
    
        MainPageService headLink = new MainPageServiceImpl();
        List<HeadLinkModel> list = headLink.selectHeadLink();
        
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("model",model);
        jsonObject.put("list",list);
        resp.getWriter().println(jsonObject);
    }
}
